/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ms.jasim.model.impl;

import ms.jasim.model.Actor;
import ms.jasim.model.Capability;
import ms.jasim.model.EvaluatorList;
import ms.jasim.model.Goal;
import ms.jasim.model.JasimTemplate;
import ms.jasim.model.ModelPackage;
import ms.jasim.model.event.EventSet;
import ms.jasim.model.event.ReactionList;
import ms.jasim.model.event.impl.EventSetImpl;
import ms.jasim.model.event.impl.ReactionListImpl;
import ms.jasim.model.items.PropertyDescriptorList;
import ms.jasim.model.items.impl.PropertyDescriptorListImpl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Jasim Template</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.jasim.model.impl.JasimTemplateImpl#getEvaluators <em>Evaluators</em>}</li>
 *   <li>{@link ms.jasim.model.impl.JasimTemplateImpl#getCustomReactions <em>Custom Reactions</em>}</li>
 *   <li>{@link ms.jasim.model.impl.JasimTemplateImpl#getEventTemplate <em>Event Template</em>}</li>
 *   <li>{@link ms.jasim.model.impl.JasimTemplateImpl#getActorDescriptors <em>Actor Descriptors</em>}</li>
 *   <li>{@link ms.jasim.model.impl.JasimTemplateImpl#getGoalDescriptors <em>Goal Descriptors</em>}</li>
 *   <li>{@link ms.jasim.model.impl.JasimTemplateImpl#getCapabilityDescriptors <em>Capability Descriptors</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class JasimTemplateImpl extends NamedModelObjectImpl implements JasimTemplate {
	/**
	 * The cached value of the '{@link #getEvaluators() <em>Evaluators</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEvaluators()
	 * @generated
	 * @ordered
	 */
	protected EvaluatorList evaluators;

	/**
	 * The cached value of the '{@link #getCustomReactions() <em>Custom Reactions</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCustomReactions()
	 * @generated
	 * @ordered
	 */
	protected ReactionList customReactions;

	/**
	 * The cached value of the '{@link #getEventTemplate() <em>Event Template</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEventTemplate()
	 * @generated
	 * @ordered
	 */
	protected EventSet eventTemplate;

	/**
	 * The cached value of the '{@link #getActorDescriptors() <em>Actor Descriptors</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActorDescriptors()
	 * @generated
	 * @ordered
	 */
	protected PropertyDescriptorList actorDescriptors;

	/**
	 * The cached value of the '{@link #getGoalDescriptors() <em>Goal Descriptors</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGoalDescriptors()
	 * @generated
	 * @ordered
	 */
	protected PropertyDescriptorList goalDescriptors;

	/**
	 * The cached value of the '{@link #getCapabilityDescriptors() <em>Capability Descriptors</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCapabilityDescriptors()
	 * @generated
	 * @ordered
	 */
	protected PropertyDescriptorList capabilityDescriptors;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	protected JasimTemplateImpl() {
		super();
		setEvaluators(new EvaluatorListImpl());
		setEventTemplate(new EventSetImpl());
		setActorDescriptors(new PropertyDescriptorListImpl());
		setGoalDescriptors(new PropertyDescriptorListImpl());
		setCapabilityDescriptors(new PropertyDescriptorListImpl());
		setCustomReactions(new ReactionListImpl());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.JASIM_TEMPLATE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EvaluatorList getEvaluators() {
		return evaluators;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public NotificationChain basicSetEvaluators(EvaluatorList newEvaluators, NotificationChain msgs) {
		EvaluatorList oldEvaluators = evaluators;
		evaluators = newEvaluators;
		evaluators.setPredefined(true);
		evaluators.setName("Evaluator");
		
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__EVALUATORS, oldEvaluators, newEvaluators);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEvaluators(EvaluatorList newEvaluators) {
		if (newEvaluators != evaluators) {
			NotificationChain msgs = null;
			if (evaluators != null)
				msgs = ((InternalEObject)evaluators).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__EVALUATORS, null, msgs);
			if (newEvaluators != null)
				msgs = ((InternalEObject)newEvaluators).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__EVALUATORS, null, msgs);
			msgs = basicSetEvaluators(newEvaluators, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__EVALUATORS, newEvaluators, newEvaluators));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ReactionList getCustomReactions() {
		return customReactions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCustomReactions(ReactionList newCustomReactions, NotificationChain msgs) {
		ReactionList oldCustomReactions = customReactions;
		customReactions = newCustomReactions;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS, oldCustomReactions, newCustomReactions);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCustomReactions(ReactionList newCustomReactions) {
		if (newCustomReactions != customReactions) {
			NotificationChain msgs = null;
			if (customReactions != null)
				msgs = ((InternalEObject)customReactions).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS, null, msgs);
			if (newCustomReactions != null)
				msgs = ((InternalEObject)newCustomReactions).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS, null, msgs);
			msgs = basicSetCustomReactions(newCustomReactions, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS, newCustomReactions, newCustomReactions));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EventSet getEventTemplate() {
		return eventTemplate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public NotificationChain basicSetEventTemplate(EventSet newEventTemplate, NotificationChain msgs) {
		EventSet oldEventTemplate = eventTemplate;
		eventTemplate = newEventTemplate;
		eventTemplate.setPredefined(true);
		eventTemplate.setName("Events");
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE, oldEventTemplate, newEventTemplate);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEventTemplate(EventSet newEventTemplate) {
		if (newEventTemplate != eventTemplate) {
			NotificationChain msgs = null;
			if (eventTemplate != null)
				msgs = ((InternalEObject)eventTemplate).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE, null, msgs);
			if (newEventTemplate != null)
				msgs = ((InternalEObject)newEventTemplate).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE, null, msgs);
			msgs = basicSetEventTemplate(newEventTemplate, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE, newEventTemplate, newEventTemplate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PropertyDescriptorList getActorDescriptors() {
		return actorDescriptors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public NotificationChain basicSetActorDescriptors(PropertyDescriptorList newActorDescriptors, NotificationChain msgs) {
		PropertyDescriptorList oldActorDescriptors = actorDescriptors;
		actorDescriptors = newActorDescriptors;
		actorDescriptors.setName("Actor Descriptors");
		actorDescriptors.setPredefined(true);
		actorDescriptors.setTargetClazz(Actor.class);
		
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS, oldActorDescriptors, newActorDescriptors);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setActorDescriptors(PropertyDescriptorList newActorDescriptors) {
		if (newActorDescriptors != actorDescriptors) {
			NotificationChain msgs = null;
			if (actorDescriptors != null)
				msgs = ((InternalEObject)actorDescriptors).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS, null, msgs);
			if (newActorDescriptors != null)
				msgs = ((InternalEObject)newActorDescriptors).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS, null, msgs);
			msgs = basicSetActorDescriptors(newActorDescriptors, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS, newActorDescriptors, newActorDescriptors));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PropertyDescriptorList getGoalDescriptors() {
		return goalDescriptors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public NotificationChain basicSetGoalDescriptors(PropertyDescriptorList newGoalDescriptors, NotificationChain msgs) {
		PropertyDescriptorList oldGoalDescriptors = goalDescriptors;
		goalDescriptors = newGoalDescriptors;
		goalDescriptors.setName("Goal Descriptors");
		goalDescriptors.setPredefined(true);
		goalDescriptors.setTargetClazz(Goal.class);
		
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS, oldGoalDescriptors, newGoalDescriptors);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGoalDescriptors(PropertyDescriptorList newGoalDescriptors) {
		if (newGoalDescriptors != goalDescriptors) {
			NotificationChain msgs = null;
			if (goalDescriptors != null)
				msgs = ((InternalEObject)goalDescriptors).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS, null, msgs);
			if (newGoalDescriptors != null)
				msgs = ((InternalEObject)newGoalDescriptors).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS, null, msgs);
			msgs = basicSetGoalDescriptors(newGoalDescriptors, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS, newGoalDescriptors, newGoalDescriptors));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PropertyDescriptorList getCapabilityDescriptors() {
		return capabilityDescriptors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public NotificationChain basicSetCapabilityDescriptors(PropertyDescriptorList newCapabilityDescriptors, NotificationChain msgs) {
		PropertyDescriptorList oldCapabilityDescriptors = capabilityDescriptors;
		capabilityDescriptors = newCapabilityDescriptors;
		capabilityDescriptors.setName("Capability Descriptors");
		capabilityDescriptors.setPredefined(true);
		capabilityDescriptors.setTargetClazz(Capability.class);
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS, oldCapabilityDescriptors, newCapabilityDescriptors);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCapabilityDescriptors(PropertyDescriptorList newCapabilityDescriptors) {
		if (newCapabilityDescriptors != capabilityDescriptors) {
			NotificationChain msgs = null;
			if (capabilityDescriptors != null)
				msgs = ((InternalEObject)capabilityDescriptors).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS, null, msgs);
			if (newCapabilityDescriptors != null)
				msgs = ((InternalEObject)newCapabilityDescriptors).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS, null, msgs);
			msgs = basicSetCapabilityDescriptors(newCapabilityDescriptors, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS, newCapabilityDescriptors, newCapabilityDescriptors));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.JASIM_TEMPLATE__EVALUATORS:
				return basicSetEvaluators(null, msgs);
			case ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS:
				return basicSetCustomReactions(null, msgs);
			case ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE:
				return basicSetEventTemplate(null, msgs);
			case ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS:
				return basicSetActorDescriptors(null, msgs);
			case ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS:
				return basicSetGoalDescriptors(null, msgs);
			case ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS:
				return basicSetCapabilityDescriptors(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.JASIM_TEMPLATE__EVALUATORS:
				return getEvaluators();
			case ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS:
				return getCustomReactions();
			case ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE:
				return getEventTemplate();
			case ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS:
				return getActorDescriptors();
			case ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS:
				return getGoalDescriptors();
			case ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS:
				return getCapabilityDescriptors();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.JASIM_TEMPLATE__EVALUATORS:
				setEvaluators((EvaluatorList)newValue);
				return;
			case ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS:
				setCustomReactions((ReactionList)newValue);
				return;
			case ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE:
				setEventTemplate((EventSet)newValue);
				return;
			case ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS:
				setActorDescriptors((PropertyDescriptorList)newValue);
				return;
			case ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS:
				setGoalDescriptors((PropertyDescriptorList)newValue);
				return;
			case ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS:
				setCapabilityDescriptors((PropertyDescriptorList)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.JASIM_TEMPLATE__EVALUATORS:
				setEvaluators((EvaluatorList)null);
				return;
			case ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS:
				setCustomReactions((ReactionList)null);
				return;
			case ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE:
				setEventTemplate((EventSet)null);
				return;
			case ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS:
				setActorDescriptors((PropertyDescriptorList)null);
				return;
			case ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS:
				setGoalDescriptors((PropertyDescriptorList)null);
				return;
			case ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS:
				setCapabilityDescriptors((PropertyDescriptorList)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.JASIM_TEMPLATE__EVALUATORS:
				return evaluators != null;
			case ModelPackage.JASIM_TEMPLATE__CUSTOM_REACTIONS:
				return customReactions != null;
			case ModelPackage.JASIM_TEMPLATE__EVENT_TEMPLATE:
				return eventTemplate != null;
			case ModelPackage.JASIM_TEMPLATE__ACTOR_DESCRIPTORS:
				return actorDescriptors != null;
			case ModelPackage.JASIM_TEMPLATE__GOAL_DESCRIPTORS:
				return goalDescriptors != null;
			case ModelPackage.JASIM_TEMPLATE__CAPABILITY_DESCRIPTORS:
				return capabilityDescriptors != null;
		}
		return super.eIsSet(featureID);
	}

} //JasimTemplateImpl
